package com.framework.modules.finance;

import com.framework.exception.util.RespResult;
import com.framework.modules.sys.controller.AbstractController;
import com.framework.page.PageUtils;
import com.framework.service.FlowTaskService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * 提现相关
 * @author wq
 */
@RestController
@RequestMapping("/sys/flowTask")
public class FlowTaskController extends AbstractController {
    @Autowired
    private FlowTaskService flowTaskService;

    /**
     * 提现列表
     * @param params
     * @return
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:take:list")
    public RespResult queryList(@RequestParam Map<String,Object> params){
        params.put("deptId",getDeptId());
        PageUtils page=flowTaskService.queryFlowTaskListForAdmin(params);
        return RespResult.ok().put("page",page);
    }

    /**
     *提现统计
     * @param params
     * @return
     */
    @RequestMapping("/countFlowTake")
    @RequiresPermissions("sys:take:list")
    public RespResult countFlowTake(@RequestParam Map<String,Object> params){
        params.put("deptId",getDeptId());
        List<Map<String, Object>> result=flowTaskService.countFlowTake(params);
        return RespResult.ok().put("page",result);
    }

    /**
     * 提交提现
     * @param ids
     * @return
     */
    @RequestMapping("commitTake")
    public RespResult commitTake(@RequestBody Long [] ids){
        String s = flowTaskService.commitTake(ids);
        return RespResult.ok(s);
    }

    /**
     * 下载
     * @return
     */
    @RequestMapping("downLoad")
    public RespResult downLoadExcel(HttpServletResponse response){
        flowTaskService.downLoadExcel(getDeptId(),response);
        return RespResult.ok();
    }

}
